#!/bin/bash

# Add defaults file, if it doesn't exist
if [[ ! -f /etc/default/lifi ]]; then
    touch /etc/default/lifi
fi

# Add lifi binary
chmod +x /usr/bin/lifi

# Set up configuration directories
if [[ ! -d /etc/cphm/ ]]; then
    mkdir -p /etc/cphm/
fi
# Set up log directories
LOG_DIR=/var/log/cphm/
test -d $LOG_DIR || mkdir -p $LOG_DIR
chown -R -L cphm:cphm $LOG_DIR
chmod 755 $LOG_DIR
if [[ ! -f /var/log/cphm/lifi.log ]]; then
    touch /var/log/cphm/lifi.log
fi



# Set up systemd service - check if the systemd directory exists per:
# https://www.freedesktop.org/software/systemd/man/sd_booted.html
if [[ -d /run/systemd/system ]]; then
    systemctl daemon-reload
    systemctl enable lifi
fi
